package com.stox.services.data.downloader.repository.file;

import com.stox.services.core.repository.AbstractCachingFileRepository;
import com.stox.services.data.downloader.model.ExchangeDownloadMetadata;
import com.stox.services.data.downloader.repository.ExchangeDownloadMetadataRepository;

public class ExchangeDownloadMetadataFileRepository extends
		AbstractCachingFileRepository<ExchangeDownloadMetadata> implements
		ExchangeDownloadMetadataRepository {
	
	public static final ExchangeDownloadMetadataFileRepository INSTANCE = new ExchangeDownloadMetadataFileRepository();

	private ExchangeDownloadMetadataFileRepository() {
		super("exchangeDownloadMetadata");
	}
	
	@Override
	public ExchangeDownloadMetadata deserialize(String text) {
		return new ExchangeDownloadMetadata(text);
	}

	@Override
	public String serialize(ExchangeDownloadMetadata entity) {
		return entity.toString();
	}

	@Override
	public void saveAndFlush(ExchangeDownloadMetadata exchangeDownloadMetadata) {
		saveOrUpdate(exchangeDownloadMetadata);
		commit();
	}
	
}
